<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

/**
 * [欢迎页面]
 */
Route::get("/","Home\IndexController@index");

/**
 * [后台路由]
 */
Route::namespace('Admin')->prefix('admin')->group(function () {
	// 登录页面
	Route::get("/","LoginController@index")->name('loginView');
	Route::get("/login/checkVerify","LoginController@checkVerify");
	Route::post("/login/login","LoginController@login");
	Route::any("/login/logout","LoginController@logout");

	// 根据节点自动加载路由
	$nodes = \App\Models\Node::where('action','<>','#')->where('router','<>','')->get();
	foreach($nodes as $node) {
		$url = "/".$node->router;
		$ctrl_action = $node->ctrl."Controller@".$node->action;
		if($node->is_resource == "是"){
			Route::resource($url,$ctrl_action);
		}else{
			Route::any($url,$ctrl_action);
		}
	}
});

/**
 * [前台路由]
 */
Route::namespace('Home')->prefix('home')->group(function () {

});
